package com.coolbi.onsupai.core.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;

import com.coolbi.onsupai.core.dao.CreditDao;
import com.coolbi.onsupai.core.entity.Credit;
import com.coolbi.onsupai.core.mapper.CreditMapper;

public class CreditDaoImpl implements CreditDao{
	
	@Autowired
	private CreditMapper creditMapper;

	public void setCreditMapper(CreditMapper creditMapper) {
		this.creditMapper = creditMapper;
	}

	@Override
	public Credit save(Credit obj) {
		creditMapper.save(obj);
		return obj;
	}

	@Override
	public int delete(long id) {
		return creditMapper.delete(id);
	}

	@Override
	public int update(Credit obj) {
		return creditMapper.update(obj);
	}

	@Override
	public Credit get(long id) {
		return creditMapper.get(id);
	}

	@Override
	public List<Credit> list() {
		
		return creditMapper.list();
	}

	@Override
	public List<Credit> listByPage(int offset, int limit) {
		Map<String,Object> parameter = new HashMap<String,Object>();
		parameter.put("offset", offset);
		parameter.put("limit", limit);
		
		return creditMapper.listByPage(parameter);
	}

	@Override
	public List<Credit> find(Map<String, Object> parameter) {
		return creditMapper.listByParameter(parameter);
	}

	@Override
	public List<Credit> findByPage(Map<String, Object> parameter, int offset,
			int limit) {
		parameter.put("offset", offset);
		parameter.put("limit", limit);
		return creditMapper.listByParameterPage(parameter);
	}

	@Override
	public List<Credit> search(Map<String, Object> parameter, int offset,
			int limit) {
		parameter.put("offset", offset);
		parameter.put("limit", limit);
		return creditMapper.search(parameter);
	}

	@Override
	public int count() {
		return creditMapper.count();
	}

	@Override
	public int countByKeyWord(Map<String, Object> parameter) {
		return creditMapper.countByKeyWord(parameter);
	}

	@Override
	public int count(Map<String, Object> parameter) {
		return creditMapper.countByParameter(parameter);
	}

}
